# --------------类的装饰器、描述符组合使用-------------------
def deco(**kwargs):
    def rapper(obj):
        for key,value in kwargs.items():
            setattr(obj,key,Typer(key,value))
        return obj
    return rapper

class Typer:
    def __init__(self,key,expect_type):
        self.key=key
        self.expect_type=expect_type
    def __get__(self, instance, owner):
        return instance.__dict__[self.key]
    def __set__(self, instance, value):
        if not isinstance(value,self.expect_type):
            raise TypeError("传入的%s不是%s类型" %(self.key,self.expect_type))
        instance.__dict__[self.key]=value
    def __delete__(self, instance):
        instance.__dict__.pop(self.key)

@deco(name=str,age=int,sex=str,saraly=float)
class People:
    # name=Typer("name",str)
    def __init__(self,name,age,sex,saraly):
        self.name=name
        self.age=age
        self.sex=sex
        self.saraly =saraly


p=People("alex",10,"女",235.000)